package learn_effective_java.item_07;

import java.math.BigInteger;
import java.util.Objects;

public class Demo {
	
	/**
	 * Return a BigInteger whose value is (this mod m). This method
	 * differs from the remainder method in that it always return a 
	 * non-negative BigInteger.
	 * 
	 * @param m the modulus, which must be positive
	 * @return this mod m
	 * @throws ArithmeticException if m is less than or equal to 0
	 */
	public BigInteger mod(BigInteger m) {
		Objects.requireNonNull(m, "m");
		if(m.signum() <= 0) {
			throw new ArithmeticException("Modulus <= 0: " + m);
		}
		
		return BigInteger.ONE;
		
	}
	
	// Private helper function for a recursive sort
	private static void sort(long a[], int offset, int length) {
		assert a != null;
		assert offset >= 0 && offset <= a.length;
		assert length >= 0 && length <= a.length - offset;
		
		// Do the computation
		System.out.println("Do the computation");
	}
	
	public static void main(String[] args) {
//		Demo d = new Demo();
//		d.mod(null);
		sort(null, -1, 0);
		foo(0);
	}
	
	private static void foo(int i) {
		assert i > 0;
		System.out.println("...");
	}
	
}
